package com.lemon.controller;
import java.util.List;

import com.lemon.domain.Result;
import com.lemon.domain.vo.SupplierVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lemon.domain.Supplier;
import com.lemon.service.SupplierService;

/**
 * 渠道商Controller
 * 
 * @author ruoyi
 * @date 2025-08-03
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController
{
    @Autowired
    private SupplierService supplierService;

    /**
     * 查询渠道商列表
     */
    @GetMapping("/list")
    public Result list()
    {
        List<Supplier> list = supplierService.getAll();
        return Result.success(list);
    }



    /**
     * 新增渠道商
     */
    @PostMapping
    public Result add(@RequestBody SupplierVo supplierVo)
    {
        supplierService.add(supplierVo);
        return Result.success();
    }

    /**
     * 修改渠道商
     */
    @PutMapping
    public Result edit(@RequestBody Supplier supplier)
    {

        return Result.success(supplierService.updateSupplier(supplier));
    }

    /**
     * 删除渠道商
     */
	@DeleteMapping("/{id}")
    public Result remove(@PathVariable Integer  id)
    {
        return Result.success(supplierService.deleteSupplierById( id));
    }
}
